<title>SC</title>
<link rel="icon" href="./../img/logo.png">
<style>
	body{
		margin: 0;
	}
	
	.home{
		width: 100%;
		height: 100%;
		background-image: url(../img/zhuce.jpg);
	}
	.zc{
		background-color: rgba(36,75,116, 0.5);
		color: #ffffff;
		border-radius: 8px;
		box-shadow:0 0 0px #000 inset;
		position: absolute;
		margin-left: 710px;
		margin-top: 150px;
		height: 400px;
		width: 500px;
	}
	.text{
		color: #ffffff;
		margin-left: 120px;
	}
	.user{
		width: 100px;
		height: 20px;
	}
	.shuru{
		margin: 30px 85px;
		width: 280px;
		text-align: center;
	}
	.t{
		
		background-color: #4E495D;
		  width:240px;;
		  height: 45px;
		  border-radius: 8px;
		  margin-bottom: 20px;
		  padding: 0 16px;
		  font-size: 18px;
		  color: #c4c3ca;
		  font-weight: 500;
		  outline: none;
		  border: none;
		  box-shadow: 0 4px 8px 0 rgba(78, 73, 79, .5);
		  transform-style: preserve-3d;
		  transform: translate3d(0, 0, 1px);
	}
	.t1{
		
		background-color: #4E495D;
		  width:150px;;
		  height: 45px;
		  border-radius: 8px;
		  margin-bottom: 20px;
		  padding: 0 16px;
		  font-size: 18px;
		  color: #c4c3ca;
		  font-weight: 500;
		  outline: none;
		  border: none;
		  box-shadow: 0 4px 8px 0 rgba(78, 73, 79, .5);
		  transform-style: preserve-3d;
		  transform: translate3d(0, 0, 1px);
		  margin-left: -90px;
	}
	
	
	.container{
		width: 100px;
		height: 100px;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		text-align: center;
		margin-top: -10px;
		margin-left: 190px;
	}
	#rec{
		fill:transparent;
		stroke:tomato;
		stroke-width: 12px;
		
		stroke-dasharray: 100 500;
		stroke-dashoffset: 230;
	}
	.btn{
		position: relative;
		
		width: 240px;
		height: 60px;
	}
	.nav{
		font-size: 23px;
		position: relative;
		top:-50px;
		letter-spacing: 6px;
	}
	@keyframes move{
		to{
			stroke-width: 4px;
			stroke-dasharray: 600;
			stroke-dashoffset: 0;
		}
	}
	
	.btn:hover #rec{
		animation: move 0.8s linear forwards;
	}
	.an{
		width: 235px;
		height: 50px;
		background-image: url(../img/kong.jpg);
		margin-top: -5px;
		border: 0;
	}
	a{
		text-decoration: none;
	}
	img{
		float: left;
		width: 40px;
		height: 40px;
	}
	.yan{
		margin-left: 210px;
		margin-top: -65px;
	}
</style>
<body >
<div class="home">
	<div class="zc">
	<form action="" method="post">
		<div class="shuru">
			<img src="../img/player.png" />
			<input type="text" name="username" class="t" placeholder="用户名"/>
		  <br><br>
			<img src="../img/ball.png" />
			<input type="password" name="password" class="t" placeholder="密码"/>
		  <br><br>
			<img src="../img/code.png" />
			<input type="text" name="code" class="t1" placeholder="验证码">
			<div class="yan">
				<a href="./login.php">
					<img src="code.php" />
				</a>
			</div>
		  <br>
		</div>
		<div class="container">
			<div class="btn">
				<svg width="240" height="60">
					<rect width="240" height="60" id="rec"/>
				</svg>
				<div class="nav">
					<input type="submit" name="submit" value="登陆" class="an"/>
				</div>
			</div>
		</div>
	</form>
	<a href="./../../StephenCurry/Home Page.html" class="text">返回首页</a>&nbsp;&nbsp;&nbsp;
	<a href="reg.php" class="text">注册</a>
	<?php
		if(isset($_POST['submit'])){
			if(empty($_POST["username"])){
				echo"<script>alert('用户名不能为空');</script>";
			}else if(empty($_POST["password"])){
				echo"<script>alert('密码不能为空');</script>";
			}else{
			    $conn=mysqli_connect("localhost","root","10a5c81626ac5ee2","user") or die("数据库链接失败！");
				$sql="select * from user where username ='".$_POST['username']."' limit 1";
				$result=mysqli_query($conn,$sql);
				$rownum=mysqli_num_rows($result);
				$rr=mysqli_fetch_array($result);
            	if($rr){
            	    echo "数据库选取成功"."<br/><br/>";
            	    if(empty($rownum['username'])){
    					if($rr['pwd']==md5($_POST['password'])){
    						setcookie("username",$rr['username']);
    						setcookie("code",md5($rr['username'].($rr['pwd'])));
    						echo "<script>alert('登陆成功！');window.location.href='index.php'</script>";
    					}else{
    						echo "<script>alert('密码错误');</script>";
    					}
    				}else{
    					echo "<script>alert('用户名不存在');</script>";
    				}
            	}else{
            	    echo "数据库选取失败"."<br/>";
            	}
				
				
			}
		}
	?>
	</div>
</div>
</body>